﻿// ===============================================================================
// XCI.WinForm.Platform 西安交通信息WinForm开发框架 2019 版权所有
// ===============================================================================

using System.Collections.Generic;
using System.ComponentModel;
using XCI.Core;
using XCI.Windows.Controls;

namespace XCI.Sys.Controls
{
    /// <summary>
    /// 角色分类下拉控件
    /// </summary>
    public class RoleCategoryComboBoxEdit : ComboBoxEditx
    {
        public override string ValueMember => "Id";
        public override string DisplayMember => "Name";

        /// <summary>
        /// 是否显示全部项
        /// </summary>
        [DefaultValue(true)]
        [Category("XCI")]
        [Description("是否显示全部项")]
        public virtual bool AllItemVisible { get; set; } = true;

        /// <summary>
        /// 全部项文本
        /// </summary>
        [DefaultValue("全部分类")]
        [Category("XCI")]
        [Description("全部项文本")]
        public virtual string AllItemCaption { get; set; } = "全部分类";

        protected override void OnLoaded()
        {
            base.OnLoaded();
            if (DesignMode) return;
            var list = new List<Simple>
            {
                new Simple("1","角色"),
                new Simple("2","职位"),
                new Simple("3","岗位"),
                new Simple("4","用户组")
            };
            if (AllItemVisible)
            {
                list.Insert(0, new Simple(string.Empty, AllItemCaption));
            }
            DataSource = list;
        }
    }
}